package com.jia.acl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jia.acl.entity.RolePermission;
import com.jia.acl.mapper.RolePermissionMapper;
import com.jia.acl.service.RolePermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dujiajia
 * @since 2021-02-03
 */
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {

    @Override
    public List<Long> selectPermissionListByRoleId(Long roleId) {
        QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
        wrapper.eq("role_id",roleId);

        List<RolePermission> rolePermissions = baseMapper.selectList(wrapper);
        List<Long> list = new ArrayList<>();
        rolePermissions.forEach(item->{
            Long permissionId = item.getPermissionId();
            list.add(permissionId);
        });
        return list;
    }
}
